<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原型链继承</title>
</head>
<body>
    <script>
        // 原型链继承：将父类的实例作为子类的原型
        function Parent() {
            this.isShow = true;
            this.info = {
                name: 'Katrina',
                age: 18,
            };
        };

        Parent.prototype.getInfo = function() {
            console.log(this.info);
            console.log(this.isShow);  // true
        };

        function Child() {};
        Child.prototype = new Parent();

        let c1 = new Child();
        c1.info.gender = 'female';
        c1.getInfo();   // {name: 'Katrina', age: 18, gender: 'female'};

        let c2 = new Child();
        c2.getInfo();   // {name: 'Katrina', age: 18, gender: 'female'};
        c2.isShow = false;

        console.log(c2.isShow);  // false
    </script>
</body>
</html>